Add a is_foreign flag to the structure. Do not call XFreePixmap on pixmaps
authorOwen Taylor <otaylor@redhat.com>
Sun, 2 Jul 2000 17:16:54 +0000 (17:16 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Sun, 2 Jul 2000 17:16:54 +0000 (17:16 +0000)
Sun Jul  2 13:06:26 2000  Owen Taylor  <otaylor@redhat.com>

* gdk/x11/gdkpixmap-x11.[ch] Changes-1.4.txt: Add a is_foreign
flag to the structure. Do not call XFreePixmap on pixmaps created
by gdk_pixmap_foreign_new().

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/Changes-1.4.txt
gdk/x11/gdkpixmap-x11.c
gdk/x11/gdkpixmap-x11.h

index 52006faeaf32ce7f042c4c10ecdeec832885b028..f08d26a2199cb8e59aeba82335616f73b9553c88 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sun Jul  2 13:06:26 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/x11/gdkpixmap-x11.[ch] Changes-1.4.txt: Add a is_foreign
+       flag to the structure. Do not call XFreePixmap on pixmaps created
+       by gdk_pixmap_foreign_new().
+
 Sun Jul  2 12:45:50 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
index 52006faeaf32ce7f042c4c10ecdeec832885b028..f08d26a2199cb8e59aeba82335616f73b9553c88 100644 (file)
@@ -1,3 +1,9 @@
+Sun Jul  2 13:06:26 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/x11/gdkpixmap-x11.[ch] Changes-1.4.txt: Add a is_foreign
+       flag to the structure. Do not call XFreePixmap on pixmaps created
+       by gdk_pixmap_foreign_new().
+
 Sun Jul  2 12:45:50 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
index 52006faeaf32ce7f042c4c10ecdeec832885b028..f08d26a2199cb8e59aeba82335616f73b9553c88 100644 (file)
@@ -1,3 +1,9 @@
+Sun Jul  2 13:06:26 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/x11/gdkpixmap-x11.[ch] Changes-1.4.txt: Add a is_foreign
+       flag to the structure. Do not call XFreePixmap on pixmaps created
+       by gdk_pixmap_foreign_new().
+
 Sun Jul  2 12:45:50 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
index 52006faeaf32ce7f042c4c10ecdeec832885b028..f08d26a2199cb8e59aeba82335616f73b9553c88 100644 (file)
@@ -1,3 +1,9 @@
+Sun Jul  2 13:06:26 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/x11/gdkpixmap-x11.[ch] Changes-1.4.txt: Add a is_foreign
+       flag to the structure. Do not call XFreePixmap on pixmaps created
+       by gdk_pixmap_foreign_new().
+
 Sun Jul  2 12:45:50 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
index 52006faeaf32ce7f042c4c10ecdeec832885b028..f08d26a2199cb8e59aeba82335616f73b9553c88 100644 (file)
@@ -1,3 +1,9 @@
+Sun Jul  2 13:06:26 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/x11/gdkpixmap-x11.[ch] Changes-1.4.txt: Add a is_foreign
+       flag to the structure. Do not call XFreePixmap on pixmaps created
+       by gdk_pixmap_foreign_new().
+
 Sun Jul  2 12:45:50 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
index 52006faeaf32ce7f042c4c10ecdeec832885b028..f08d26a2199cb8e59aeba82335616f73b9553c88 100644 (file)
@@ -1,3 +1,9 @@
+Sun Jul  2 13:06:26 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/x11/gdkpixmap-x11.[ch] Changes-1.4.txt: Add a is_foreign
+       flag to the structure. Do not call XFreePixmap on pixmaps created
+       by gdk_pixmap_foreign_new().
+
 Sun Jul  2 12:45:50 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
index 52006faeaf32ce7f042c4c10ecdeec832885b028..f08d26a2199cb8e59aeba82335616f73b9553c88 100644 (file)
@@ -1,3 +1,9 @@
+Sun Jul  2 13:06:26 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/x11/gdkpixmap-x11.[ch] Changes-1.4.txt: Add a is_foreign
+       flag to the structure. Do not call XFreePixmap on pixmaps created
+       by gdk_pixmap_foreign_new().
+
 Sun Jul  2 12:45:50 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
index 974f51e8378dd6c7150dafd5040bfd1b35851bb4..5b4f2507d741252ae2eb0e37e7b70c966e87c945 100644 (file)
@@ -184,5 +184,9 @@ Incompatible Changes from GTK+-1.2 to GTK+-1.4:
 
   #define gdk_rgb_get_cmap               gdk_rgb_get_colormap
 
-
-
+- gdk_pixmap_foreign_new() no longer calls XFreePixmap() on the 
+  pixmap when the GdkPixmap is finalized. This change corresponds
+  to the behavior of gdk_window_foreign_new(), and fixes a lot
+  of problems with code where the pixmap wasn't supposed to be
+  freed. If XFreePixmap() is needed, it can be done using the
+  destroy-notification facilities of g_object_set_data().
\ No newline at end of file
index 9bef142f306bfd3d247d0d39d8ba07cd2fd36089..618c21fa5d01468da54f130bfa882f0b64f4f526 100644 (file)
@@ -120,8 +120,10 @@ gdk_pixmap_impl_x11_finalize (GObject *object)
 {
   GdkPixmapImplX11 *impl = GDK_PIXMAP_IMPL_X11 (object);
   GdkPixmap *wrapper = GDK_PIXMAP (GDK_DRAWABLE_IMPL_X11 (impl)->wrapper);
+
+  if (!impl->is_foreign)
+    XFreePixmap (GDK_PIXMAP_XDISPLAY (wrapper), GDK_PIXMAP_XID (wrapper));
   
-  XFreePixmap (GDK_PIXMAP_XDISPLAY (wrapper), GDK_PIXMAP_XID (wrapper));
   gdk_xid_table_remove (GDK_PIXMAP_XID (wrapper));
   
   G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -171,10 +173,11 @@ gdk_pixmap_new (GdkWindow *window,
                                   GDK_WINDOW_XID (window),
                                   width, height, depth);
   
+  pix_impl->is_foreign = FALSE;
   pix_impl->width = width;
   pix_impl->height = height;
   GDK_PIXMAP_OBJECT (pixmap)->depth = depth;
-
+  
   gdk_xid_table_insert (&GDK_PIXMAP_XID (pixmap), pixmap);
 
   return pixmap;
@@ -205,6 +208,7 @@ gdk_bitmap_create_from_data (GdkWindow   *window,
   pix_impl = GDK_PIXMAP_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl);
   draw_impl->wrapper = GDK_DRAWABLE (pixmap);
 
+  pix_impl->is_foreign = FALSE;
   pix_impl->width = width;
   pix_impl->height = height;
   GDK_PIXMAP_OBJECT (pixmap)->depth = 1;
@@ -253,6 +257,7 @@ gdk_pixmap_create_from_data (GdkWindow   *window,
   pix_impl = GDK_PIXMAP_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl);
   draw_impl->wrapper = GDK_DRAWABLE (pixmap);
   
+  pix_impl->is_foreign = FALSE;
   pix_impl->width = width;
   pix_impl->height = height;
   GDK_PIXMAP_OBJECT (pixmap)->depth = depth;
@@ -301,6 +306,7 @@ gdk_pixmap_foreign_new (GdkNativeWindow anid)
   draw_impl->xdisplay = GDK_DISPLAY ();
   draw_impl->xid = xpixmap;
 
+  pix_impl->is_foreign = TRUE;
   pix_impl->width = w_ret;
   pix_impl->height = h_ret;
   GDK_PIXMAP_OBJECT (pixmap)->depth = depth_ret;
index 0087553ba71a3a16b2e54be1f8820a9f76f2888b..2704989dca36356033f02e22abb421c9b3d40ad0 100644 (file)
@@ -53,6 +53,8 @@ struct _GdkPixmapImplX11
 
   gint width;
   gint height;
+
+  guint is_foreign : 1;
 };
  
 struct _GdkPixmapImplX11Class